package com.rd.student.ruanjian.class4.wangxingkai.Exam;

import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

public class Student {
    public static void main(String[] args) {
        try {
            FileWriter writer = new FileWriter("Student.txt");
            writer.write("姓名\t语文成绩\t数学成绩\t总分\n");
            Scanner scanner = new Scanner(System.in);
            for (int i = 0; i < 3; i++) {
                System.out.println("请输入第 " + (i + 1) + " 个学生的姓名：");
                String name = scanner.next();
                System.out.println("请输入第 " + (i + 1) + " 个学生的语文成绩：");
                int chineseScore = scanner.nextInt();
                System.out.println("请输入第 " + (i + 1) + " 个学生的数学成绩：");
                int mathScore = scanner.nextInt();
                int totalScore = chineseScore + mathScore;
                writer.write(name + "\t" + chineseScore + "\t" + mathScore + "\t" + totalScore + "\n");
            }
            writer.close();
            System.out.println("完毕，查看文件");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
